class Solution:
    def longestPalindrome(self, s: str) -> str:
        self.start = 0
        self.length = 1
        for i in range(len(s)-1):
            if s[i] == s[i + 1]:
                a = i
                b = i + 1
                self.compare(a, b, s)
            if i > 0 and s[i - 1] == s[i + 1]:
                a = i - 1
                b = i + 1
                self.compare(a, b, s)

        return s[self.start:self.start+self.length]
    def compare(self, a, b, s):
        while a >= 0 and b < len(s) and s[a] == s[b]:
            a -= 1
            b += 1
        if self.length < len(s[a + 1:b]):
            self.start = a + 1
            self.length = len(s[a + 1:b])

if __name__ == '__main__':
    s = Solution()
    print(s.longestPalindrome("acbababc"))